using System;
using System.Globalization;
using jSLApp.Client.Workflow;
using jSLCore.Client.Presentation.Authorization;
using jSLCore.Client.Presentation.jBinding;

namespace jSLApp.Client.Converters
{
    public class AuthorIsCurrentUserConverter : jChainConverter
    {
        private bool _allowModerators=true;
        public bool AllowModerators
        {
            get { return _allowModerators; }
            set { _allowModerators = value; }
        }

        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!jSecurity.IsAuthorized) return false;

            var str = value as string;
            if(AllowModerators) return str.IsAllowedToChangeMusic();
            else
            {
                return str.IsCurrentAuthor();
            }
        }

        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}